import { defineStore } from "pinia";

export const useTabStore = defineStore({
  id: "tab",
  state: () => ({
    tab: "Home",
    username: "",
    avatar: "",
    userId: "",
    loginStatus: false,
    assembly_type: "CPU",
    assembly_data: [],
    searchKey: {},
    theme: "auto",
  }),
  actions: {
    setTheme(theme: string) {
      this.theme = theme;
    },

    setTab(tab: string) {
      this.tab = tab;
    },
    setUserName(username: string) {
      this.username = username;
    },
    setAvatar(avatar: string) {
      this.avatar = avatar;
    },
    setLoginStatus(loginStatus: boolean) {
      this.loginStatus = loginStatus;
    },
    setAssemblyType(assembly_type: string) {
      this.assembly_type = assembly_type;
    },
    setAssemblyData(assembly_data: any) {
      this.assembly_data = assembly_data;
    },
    setUserId(userId: string) {
      this.userId = userId;
    },
    // 向searchKey中添加数据
    setSearchKey(key: string, value: string) {
      this.searchKey[key] = value;
    },
  },
});
